import DialogBaseUI from "../custom/DialogBaseUI";
import {Config} from "../Config";
import {SoundData} from "../data/SoundData";

const {ccclass, property} = cc._decorator;
@ccclass
export default class SetUI extends DialogBaseUI {
    @property(cc.Label)
    version = null
    @property(cc.Node)
    musicHanler = null;
    @property(cc.Node)
    effectHanler = null;
    onEnable(){
        this.version.string = "版本号:"+Config.VERSION;
        this.musicHanler.getComponent(cc.Slider).progress = SoundData.music;
        this.effectHanler.getComponent(cc.Slider).progress = SoundData.effect;
        this.onSliderMusic();
        this.onSliderEffect();
        super.onEnable();
    }

    onSliderMusic(){
        let musicBar = this.musicHanler.getComponent(cc.ProgressBar);
        let musicSlider = this.musicHanler.getComponent(cc.Slider);
        musicBar.progress = musicSlider.progress;
        SoundData.music = musicBar.progress;
    }

    onSliderEffect(){
        let effectBar = this.effectHanler.getComponent(cc.ProgressBar);
        let effectSlider = this.effectHanler.getComponent(cc.Slider);
        effectBar.progress = effectSlider.progress;
        SoundData.effect = effectBar.progress;
    }

}